package com.yjhb.android.sbz.mvp.refreshrecord;

import com.yjhb.android.sbz.entity.FlushRecord;
import com.yjhb.android.sbz.entity.ResultSet;
import com.yjhb.android.sbz.http.HttpObserver;
import com.yjhb.android.sbz.http.HttpTool;
import com.yjhb.android.sbz.mvp.ConventionPresenter;

/**
 * 创建者 zx
 * 创建时间 2020/12/7 15:20
 */
public class RefreshRecordPresenter extends ConventionPresenter<RefreshRecordView> {
    private final String TAG = "RefreshRecordPresenter";

    @Override
    protected void onDestroy() {

    }

    public RefreshRecordPresenter(RefreshRecordView refreshRecordView) {
        super(refreshRecordView);
    }

    public void getFlushHistory(int size, final int current) {
        HttpTool.request(model.getFlushHistory(size, current), new HttpObserver<ResultSet<FlushRecord>>() {
            @Override
            public void onResult(ResultSet<FlushRecord> data) {
                if (view != null) {
                    if (current == 1)
                        view.onRefresh(data.getRecords());
                    else
                        view.onLoad(data.getRecords());
                }
            }

            @Override
            public void onError(int code, String msg) {
                if (view != null) {
                    view.onFailure(code, msg);
                }
            }
        });
    }

}
